/**
 * Project Name:poll
 * File Name:Swagger2.java
 * Package Name:com.briup.apps.poll.config
 * Date:2018年6月10日下午6:22:51
 * Copyright (c) 2018, chenzhou1025@126.com All Rights Reserved.
 *
*/

package com.briup.apps.zhaopin.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author CC
 * @Description Swagger2 版本2.9.2
 * @Date 2019/9/20 9:47
 **/

@Configuration
@EnableSwagger2
public class Swagger2 {
	@Bean
	public Docket createRestApi() {
	    // token
		List<Parameter> parameters = new ArrayList<>();
		parameters.add(new ParameterBuilder()
				.name("token")
				.description("认证token")
				.modelRef(new ModelRef("string"))
				.parameterType("header")
				.required(false)
				.build());
		return new Docket(DocumentationType.SWAGGER_2)
				.apiInfo(apiInfo())
//				.globalOperationParameters(parameters) // token
				.select()
				.apis(RequestHandlerSelectors.basePackage("com.briup.apps.zhaopin.web"))
				.paths(PathSelectors.any())
				.build();
	}
	
	private ApiInfo apiInfo() {
		return new ApiInfoBuilder()
				.title("广西科技大学校园招聘网API")
				.description("昆山杰普软件科技有限公司 http://www.briup.com")
				.version("1.0")
				.build();
	}
}

